home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / DNA_XCMD / COMPLIME.C < prev    next >
C/C++ Source or Header  |  1991-09-01  |  1KB  |  42 lines

  1. /*    Compliment.c
  2.     
  3.     A HyperCard XFCN that returns the compliment of a DNA sequence. It uses the base
  4.     conversion routine 'BaseComp.c' to map the individual bases; look there to find the
  5.     compliment function.
  6.     
  7.     Molecular Genetics Laboratory, The Salk Institute
  8.     Division of Biology & Dept. of Comp. Sci, Washington University
  9.     America OnLine: Reece            Internet: reece@informatics.wustl.edu
  10.  
  11.     To compile (Think C):
  12.         1) Create project with this file, BaseComp.c, MacTraps, ANSI-A4, and HyperXLib.
  13.         2) Choose 'Set Project Type╔'. Select type 'Code Resource',
  14.             name 'Compliment', type 'XFCN', and ID '2000'.
  15.         3) Select 'Build Code Resource╔" from Project menu.
  16. */
  17.  
  18.  
  19.  
  20. #include <HyperXCmd.h>
  21. #include "BaseComp.h"
  22. #include "string.h"
  23. #define        NIL        ((void *) 0)
  24.  
  25. pascal    void    main(XCmdPtr  paramPtr)
  26. {
  27.     Handle                ReturnHdl;
  28.     register    char    *i, *j;
  29.  
  30.     /*    Allocate space that is as large as the incoming sequence + 1 for '\0'.  If
  31.         allocation fails, we return a NIL handle.                                    */
  32.     if ( (ReturnHdl = (Handle) NewHandle ((long) strlen(*paramPtr->params[0])+1)) != NIL )
  33.         {
  34.         for (i = *paramPtr->params[0], j = *(char **)ReturnHdl; *i; i++, j++)
  35.             *j = BaseCompliment(*i);
  36.         
  37.         *j = '\0';    /*    tack on the null at the end of the out-going sequence.        */
  38.         }
  39.         
  40.     paramPtr->returnValue = ReturnHdl;
  41. }
  42.